﻿@{
    ViewBag.Title = "Robot";
    Layout = "~/Views/Shared/_Dashboard.cshtml";
}
@UIHelper.ImageTitle("robots.txt " + Html.Global("RES_EDITOR"), Html.Global("RobotEditor_Desc"), "~/content/images/icon_full_page_48.png")
@using (Html.BeginForm())
{
    @UIHelper.SectionHeader(Html.Global("RobotEditor_SpecifyRules"))

    if (!string.IsNullOrEmpty(ViewBag.Error))
    { 
    <div class="ui-state-error" style="padding: 20px;">
        @ViewBag.Error
    </div>
    }
    
    <table>
        <tr>
            <td>
                @Html.Global("RobotEditor_Action")
            </td>
            <td>
                User-agent
            </td>
            <td>@Html.Global("RobotEditor_DirsAndFiles")
            </td>
            <td>
            </td>
        </tr>
        <tr>
            <td valign="top">
                @(Ajax.Dna().ComboBox("cbOperations")
                .Select("Allow")
         .DropDownStyle(DropdownStyles.DropdownList)
            .Items(items =>
            {
                items.AddValue("Allow", "Allow");
                items.AddValue("Disallow", "Disallow");
            })
            .GetHtml())
            </td>
            <td valign="top">@(Ajax.Dna().ComboBox("cbUserAgents")
            .Select("*")
            .DropDownStyle(DropdownStyles.Dropdown)
            .Items(items =>
            {
                items.AddValue("All", "*");
                items.AddValue("Googlebot", "Googlebot");
                items.AddValue("Googlebot-Mobile", "Googlebot-Mobile");
                items.AddValue("Googlebot-Image", "Googlebot-Image");
                items.AddValue("Mediapartners-Google", "Mediapartners-Google");
                items.AddValue("Adsbot-Google", "Adsbot-Google");
                items.AddValue("Baiduspider", "Baiduspider");
                items.AddValue("Bloglines subscriber", "Bloglines subscriber");
                items.AddValue("Charlotte 0.9t", "Charlotte 0.9t");
                items.AddValue("Charlotte 1.1", "Charlotte 1.1");
                items.AddValue("DotBot 1.1", "DotBot 1.1");
                items.AddValue("eCairn Grabber 1.0", "eCairn Grabber 1.0");
                items.AddValue("FeedFetcher-Google", "FeedFetcher-Google");
                items.AddValue("LinkWalker", "LinkWalker");
                items.AddValue("LiteFinder 1.0", "LiteFinder 1.0");
                items.AddValue("msnbot 1.1", "msnbot 1.1");
                items.AddValue("msnbot-media 1.0", "msnbot-media 1.0");
                items.AddValue("msnbot-media 1.1", "msnbot-media 1.1");
                items.AddValue("msnbot/2.0b", "msnbot/2.0b");
                items.AddValue("QihooBot", "QihooBot");
                items.AddValue("Sogou head spider 3.0", "Sogou head spider 3.0");
                items.AddValue("Sogou web spider/4.0", "Sogou web spider 4.0");
                items.AddValue("Sosoimagespider", "Sosoimagespider");
                items.AddValue("Sosospider", "Sosospider");
                items.AddValue("Sosospider+", "Sosospider+");
                items.AddValue("Speedy Spider", "Speedy Spider");
                items.AddValue("Superdownloads Spiderman", "Superdownloads Spiderman");
                items.AddValue("WebAlta Crawler 2.0", "WebAlta Crawler 2.0");
                items.AddValue("Yahoo! Slurp", "Yahoo! Slurp");
                items.AddValue("Yahoo! Slurp 3.0", "Yahoo! Slurp 3.0");
                items.AddValue("Yahoo! Slurp China", "Yahoo! Slurp China");
                items.AddValue("Yeti 1.0", "Yeti 1.0");
                items.AddValue("YodaoBot 1.0", "YodaoBot 1.0");
                items.AddValue("YoudaoBot 1.0", "YoudaoBot 1.0");
            })
            .GetHtml())
            </td>
            <td>
                @Ajax.Dna().TextBox("txtVPath").Width(300).GetHtml()
                @MvcHtmlString.Create(Html.Global("RobotEditor_DirsAndFiles_Tips"))
            </td>
            <td valign="top">
                @Ajax.Dna().Button("btnAdd").LocText("RobotEditor_AddRule").Click("_addRule();").GetHtml()
            </td>
        </tr>
    </table>  
    
    @UIHelper.SectionHeader("robot.txt")
    @Ajax.Dna().TextArea("Rules").Width(590).Height(200).Value(ViewBag.Rules).Resizable().GetHtml()
    <div>
        @Ajax.Dna().Button().LocText("RES_SAVE").Submit().GetHtml()
    </div>
}
<script type="text/javascript">
    function _addRule() {
        var _o = $("#cbOperations").val(),
        _ua = $("#cbUserAgents").val(),
        _path = $("#txtVPath").val();

        if (_o == "") { $("#cbOperations").focus(); return; }
        if (_ua == "") { $("#cbUserAgents").focus(); return; }
        if (_path == "") { $("#txtVPath").focus(); return; }
        var _r = $("#Rules").val();
        var _newRule = "User-agent:" + _ua + "\t\n" + _o + ":" + _path;
        if (_r) $("#Rules").val(_r + "\t\n" + _newRule);
        else $("#Rules").val(_newRule);
    }
</script>
